package app {
	
	/**
	 * ...
	 * @author hungconcon
	 */
	public class wadawdwd {
		
		public function wadawdwd() {
			//Action tag #0
			
			r.px = p._x;
			r.py = p._y;
			xs = r.pspeed;
			r.act = "stand";
			pymin = 10;
			pymax = 200;
			powermax = 31;
			powermin = 15;
			powerrange = powermax - powermin;
			onMouseDown = function() {
				if (r.hold && !stat.speaker.hitTest(r._xmouse, r._ymouse, 1)) {
					powerdiv = (pymax - Math.max(pymin, Math.min(pymax, r._ymouse))) / (pymax - pymin);
					delete onEnterFrame;
					delete onMouseDown;
					gotoAndPlay("shoot");
				}
			}
			;
			onEnterFrame = function() {
				r.oldx = r.px;
				r.px = Math.max(r.xmin, Math.min(r._xmouse, r.xmax));
				r.py = Math.max(r.ymin, Math.min(r._ymouse, r.ymax));
				dx = r.px - p._x;
				Math.abs(dx) > 1 ? (dx > 0 ? (r.hd = 1) : (r.hd = 2)) : null;
				if (Math.abs(dx) > Math.abs(xs)) {
					++runtime;
					moving = 500;
					dx > 0 ? (nx = p._x + xs) : (nx = p._x - xs);
					p._x = nx;
				} else {
					if (runtime > 3) {
						p._x = r.px;
						moving = runtime = 0;
					} else if (Math.abs(dx) > 3) {
						p._x = r.px;
						moving = 500;
					}
					moving > 495 ? (moving = 5) : (moving > 5 ? (moving = 0) : null);
				}
				moving > 0 ? moving-- : null;
				r.act = "run";
				if (Math.abs(r.oldx - r.px) < 1) {
					!moving || p._x == r.xmax || p._x == r.xmin ? (r.act = "stand") : null;
				}
				p.gotoAndStop(r.act + r.hold);
				r.hd == 1 ? (p._xscale = 100) : (p._xscale = -100);
				if (r.hold) {
					return undefined;
				}
				closeball = undefined;
				balldist = 1000;
				var __reg1 = 0;
				while (__reg1 < r.balls.length) {
					if (r.balls[__reg1]._y > 270) {
						dx = Math.abs(r.balls[__reg1]._x - p._x);
						if (dx < 40 && dx < balldist) {
							balldist = dx;
							closeball = r.balls[__reg1];
						}
					}
					++__reg1;
				}
				if (balldist < 1000) {
					r.hold = 1;
					r.ballcolor = closeball.bcolor;
					r.balls.removeValue(closeball);
					closeball.removeMovieClip();
					r.zgrab.start();
				}
			}
			stop();
		
		}
	
	}

}